<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%--数据统计页--%>
<html>
<head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="../static/layui/css/layui.css">
    <style>
        .fade-in-left {
            animation: fade-in-left 0.6s cubic-bezier(0.390, 0.575, 0.565, 1.000) both;
        }

        @keyframes fade-in-left {
            0% {
                transform: translateX(-50px);
                opacity: 0;
            }
            100% {
                transform: translateX(0);
                opacity: 1;
            }
        }
    </style>
</head>
<body class="fade-in-left" style="padding: 8px;">

<div class="layui-row layui-col-space10">
    <div class="layui-col-md6">
        <div class="layui-panel">
            <div id="main" style="padding: 30px; height: 250px">一个面板</div>
        </div>
    </div>

    <div class="layui-col-md6">
        <div class="layui-panel">
            <div id="main1" style="padding: 30px; height: 250px"></div>
        </div>
    </div>
</div>

<div class="layui-row">
    <div class="layui-col-md12">
        <div class="layui-panel">
            <div id="main2" style="padding: 30px; height: 250px">一个面板</div>
        </div>
    </div>
</div>

<script src="../static/bootstrap-dist/js/jquery-3.5.1.js"></script>
<script src="../static/echarts-dist/echarts.min.js"></script>
<script src="../static/layui/layui.js"></script>
<script>
    let myChart = echarts.init(document.getElementById("main"));
    let myChart1 = echarts.init(document.getElementById("main1"));
    let myChart2 = echarts.init(document.getElementById("main2"));
    let typeDate=[];
    let numDate=[];
    let pieDate=[];
    let lineDate=[];
    let lineRelation=[];
    let lineReationDate1=[];
    let lineReationDate2=[];
    let lineReationDate3=[];
    let lineReationDate4=[];
    let lineReationDate5=[];

    $(function () {
        $.ajax({
            url: "feastType",
            method: "post",
            dataType: "json",
            data:{
                "opr":"getFeastInfo"
            },
            beforeSend : function (){
                layer.load(2);
            },
            complete: function () {
                layer.closeAll();
            },
            success: function (data) {
                console.log(data);
                for (let i=0;i<data.tree.length;i++){
                    numDate.push(data.tree[i].treeCountArr)
                    typeDate.push(data.tree[i].treeTypeArr)
                }
                for (let i=0;i<data.pie.length;i++){
                    pieDate.push(
                        {
                            "value":data.pie[i].pieCountArr,"name":data.pie[i].pieTypeArr
                        }
                        )
                }
                for (let i=0;i<data.lineDates.length;i++){
                    lineDate.push(data.lineDates[i].attendData);
                }
                for (let i=0;i<data.lineRelationDataList.length;i++){
                    lineRelation.push(data.lineRelationDataList[i].relationTypeName);
                }
                for (let i=0;i<data.lineTotalLists[0].list.length;i++){
                    lineReationDate1.push(data.lineTotalLists[0].list[i].count)
                }
                for (let i=0;i<data.lineTotalLists[1].list.length;i++){
                    lineReationDate2.push(data.lineTotalLists[1].list[i].count)
                }
                for (let i=0;i<data.lineTotalLists[2].list.length;i++){
                    lineReationDate3.push(data.lineTotalLists[2].list[i].count)
                }
                for (let i=0;i<data.lineTotalLists[3].list.length;i++){
                    lineReationDate4.push(data.lineTotalLists[3].list[i].count)
                }
                for (let i=0;i<data.lineTotalLists[4].list.length;i++){
                    lineReationDate5.push(data.lineTotalLists[4].list[i].count)
                }
                let option2 = {
                    title: {
                        text: '礼金收入分析'
                    },
                    tooltip: {
                        trigger: 'axis'
                    },
                    legend: {
                        data: lineRelation
                    },
                    grid: {
                        left: '3%',
                        right: '4%',
                        bottom: '3%',
                        containLabel: true
                    },
                    toolbox: {
                        feature: {
                            saveAsImage: {}
                        }
                    },
                    xAxis: {
                        type: 'category',
                        boundaryGap: false,
                        data: lineDate
                    },
                    yAxis: {
                        type: 'value'
                    },
                    series: [
                        {
                            name:lineRelation[0],
                            type: 'line',
                            stack: '总量',
                            data: lineReationDate1
                        },
                        {
                            name: lineRelation[1],
                            type: 'line',
                            stack: '总量',
                            data:lineReationDate2
                        },
                        {
                            name: lineRelation[2],
                            type: 'line',
                            stack: '总量',
                            data: lineReationDate3
                        },
                        {
                            name: lineRelation[3],
                            type: 'line',
                            stack: '总量',
                            data:lineReationDate4
                        },
                        {
                            name: lineRelation[4],
                            type: 'line',
                            stack: '总量',
                            data: lineReationDate5
                        }
                    ]
                };
                myChart.setOption(option);
                myChart1.setOption(option1);
                myChart2.setOption(option2);
            },
            error: function () {
                layer.alert("宴会数据请求失败");
            }
        });
    })
    // 基于准备好的dom，初始化echarts实例

    let option = {
        title: {
            text: '宴会类型分析'
        },
        tooltip: {},
        legend: {
            data:['举办次数']
        },
        xAxis: {
            data:typeDate //["生日宴", "婚宴", "寿宴", "满月酒", "接风宴", "公务宴"]
        },
        yAxis: {},
        series: [{
            name: '举办次数',
            type: 'bar',
            data: numDate
        }]
    };

    // 指定图表的配置项和数据
    let option1 = {
        title: {
            text: '礼金支出分析',
            left: 'center'
        },
        tooltip: {
            trigger: 'item'
        },
        legend: {
            orient: 'vertical',
            left: 'left',
        },
        series: [
            {
                name: '支出',
                type: 'pie',
                radius: '50%',
                data:pieDate ,
                emphasis: {
                    itemStyle: {
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                    }
                }
            }
        ]
    };
    // 使用刚指定的配置项和数据显示图表。

</script>
</body>
</html>
